/*
 * coveringPackingMiscellaneous.h
 *
 *  Created on: May 14, 2013
 *      Author: sjelic
 */

#ifndef COVERINGPACKINGMISCELLANEOUS_H_
#define COVERINGPACKINGMISCELLANEOUS_H_

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <string>
#include <math.h>
#include <assert.h>
#include <sys/time.h>
#include <algorithm>
#include <iomanip>
#define index int

namespace Miscellaneous{

	//functions
	template <typename T>
	T** AllocateDynamicArray(int, int);

	template <typename T>
	void FreeDynamicArray(T**);

	template<class T>
	void printContainer(T  *ptr, index size);

	template<class T>
	void printMatrix(T *ptr, index rows,index cols);

	//void convertRailFormatToYoung(std::string,std::string);


	void experimentUsage();

	//classes

	class Timer
	{
		private:
			off_t _usecs;//! The timer value (initially zero)
			off_t _usecs_at_mark;//! The timer value at the last mark set (initially zero)
			struct timeval _tstart;//! Used by the gettimeofday command.
			struct timeval _tend;//! Used by the gettimeofday command.
			struct timezone _tz; //! Used by the gettimeofday command.
			bool _running;//! Indicates whether a measurement is running.

		public:
			Timer();//! The default constructor.
			void reset();//! Resets the timer value to zero and stops the measurement.
			void mark();//! Mark the current point in time (to be considered by next usecs_since_mark)
			void start();//! Resets the timer value to zero and starts the measurement.
			void cont();//! Continues the measurement without resetting the timer value (no effect it running)
			void stop();//! Stops the measurement (does *not* return the timer value anymore)
			//! Time at last stop (initially zero)
			off_t value() const;  /* in microseconds */
			off_t usecs() const;  /* in microseconds */
			off_t msecs() const;  /* in milliseconds */
			float msecs_float() const;
			float secs() const; /* in seconds */
			off_t usecs_since_mark() const; //! Time from last mark to last stop (initally zero)
	};
}


#endif /* COVERINGPACKINGMISCELLANEOUS_H_ */
